package com.gz.droolsrule.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gz.droolsrule.dao.BaseRuleActionParamValueInfoMapper;
import com.gz.droolsrule.pojo.BaseRuleActionParamValueInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName: RuleActionParamValueService <br/>
 * Description: <br/>
 * date: 2019/5/31 16:00<br/>
 *
 * @author gz<br />
 * @since JDK 1.8
 */
@Service
public class RuleActionParamValueService {
    @Autowired
    private BaseRuleActionParamValueInfoMapper baseRuleActionParamValueInfoMapper;

    /**
     * 方法说明: 根据动作参数或动作与规则关系id获取对应的参数信息
     *
     * @param baseRuleActionParamValueInfo 参数
     * @param page                         分页参数
     */
    public PageInfo<BaseRuleActionParamValueInfo> findBaseRuleActionParamValueInfoPage(BaseRuleActionParamValueInfo baseRuleActionParamValueInfo, PageInfo page) {
        PageHelper.startPage(page.getPageNum(), page.getPageSize());
        List<BaseRuleActionParamValueInfo> list = this.baseRuleActionParamValueInfoMapper.findBaseRuleActionParamValueInfoList(baseRuleActionParamValueInfo);
        return new PageInfo<>(list);
    }

    /**
     * 方法说明: 根据参数id获取参数value
     *
     * @param paramId 参数id
     */
    public BaseRuleActionParamValueInfo findRuleParamValueByActionParamId(Long paramId) {
        if (null == paramId) {
            return null;
        }
        return this.baseRuleActionParamValueInfoMapper.findRuleParamValueByActionParamId(paramId);
    }
}
